package com.swxy.club.controller;


import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.swxy.club.dto.User;
import com.swxy.club.feignClient.UserServiceFeignClient;
import com.swxy.club.result.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


/**
 * @author 易
 */

@RequestMapping("/api")
@RequiredArgsConstructor
@RestController
public class TestController {


    private final UserServiceFeignClient userFeignClient;

    @GetMapping
    public Result test(){
        List<Long> userIds = Arrays.asList(1L, 2L, 3L);
        Result result = userFeignClient.selectUsers(userIds);
        List<User> data = Convert.toList(User.class, ObjectUtil.defaultIfNull(result.getData(), new ArrayList<>()));
        System.out.println(data);
        return result;
    }

    @GetMapping("test")
    public Result test2(){
        return userFeignClient.selectCurrentUser();
    }

}
